package com.colin.aiyi.dao.ImpxUtils;

import com.colin.aiyi.app.Constant;
import com.colin.aiyi.entity.response.BaseResponse;
import com.colin.aiyi.entity.User;

import org.xutils.http.RequestParams;

/**
 * Created by hl on 2017/6/11.
 */

public class ImpUpdatePassword extends AbsServicexUtils{
    @Override
    public void onSuccess(String result) {
        super.onSuccess(result);
        BaseResponse loginResponse=gson.fromJson(result,BaseResponse.class);
        if (callback==null)
        {
            sendMsgToView(loginResponse);
        }else {
            callback.onSuccess(loginResponse);
        }
    }

    @Override
    public <V> void getObject(V v) {
        super.getObject(v);
        User user= (User) v;
        RequestParams parems=new RequestParams(Constant.updatePassword);
        parems.addBodyParameter("newPassword",user.getPassword());
        parems.addBodyParameter("oldPassword",user.getPasswdOld());
        parems.addBodyParameter("accessToken", user.getAccessToken());
        parems.addBodyParameter("clientId",Constant.CLIENT_ID);
        parems.addBodyParameter("clientSecret",Constant.CLIENT_SECRET);
        sendToServer(parems,1);
    }
}
